<?php
namespace Home\Controller;
use Think\Controller;

class IndexController extends Controller{
    function __construct(){
        parent::__construct();
        // if(!$_SESSION['loginUser']){
        //     $this->redirect('/user/login');
        // }else{
        //     $this->redirect('/admin');
        // }
    }

    public function index(){
        $this->title = '《奔跑吧》官方手游预约';
        $this->description = '《奔跑吧》官方手游现已开放预约，海量R币钻石，高级时装宠物等你来领取。';
        $this->keywords = '奔跑吧,浙江卫视,Z视介,跑男';
        $this->pid = 10001;
        if(F('YUYUE_COUNT_'.$this->pid) == NULL){
            $count = D('GameYuyueUser')->where(['pid' => $this->pid])->count(); //存储缓存
            F('YUYUE_COUNT_'.$this->pid,$count);
        }else{
            $count = F('YUYUE_COUNT_'.$this->pid);
        }
        $this->totalCount = $count;
        $this->display();
    }

    public function index2(){
        // $content = json_encode(I('get.'));
        // $arr = json_decode($content, true);
        // $text = "一些文本"; // 假设这是外部输入或文件内容
        // $text = $arr['id'];
        // $encodedText = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text));
        // dump($encodedText);
        // $data['content'] = $encodedText;
        $data['content'] = '🍪';
        M('TvGameClue')->add($data);
        die();
        $this->title = '《奔跑吧》官方手游预约';
        $this->description = '《奔跑吧》官方手游现已开放预约，海量R币钻石，高级时装宠物等你来领取。';
        $this->keywords = '奔跑吧,浙江卫视,Z视介,跑男';
        $this->display();
    }

    public function manage(){
        $tag_group_tree = D('AimusicTagGroup')->where(['status' => 1])->order('listorder desc')->select();
        foreach($tag_group_tree as $key => $val){
            $tag_group_tree[$key]['tag_list'] = D('AimusicTag')->where(['group_id' => $val['id'], 'status' => 1])->order('listorder desc')->select();
        }
        $this->tag_group_tree = $tag_group_tree;
        $this->display();
    }
}